<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="Cache-Control" content="No-Cache">
	<meta http-equiv="Pragma" content="No-Cache">

	<title>운세의 신</title>

	<link rel="stylesheet" type="text/css" href="/css/common.css">
	
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
	<script src="/js/common_basic.js"></script>
	<script src="/js/lib/jquery.inducer.js"></script>
	<script src="/js/utility/common_util.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			
			$("#photo_url").inducer("미입력시 서비스 화면은 네이버 이미지로 대체됩니다.");
			
			var modLayer = $("#modLayer");
			
			var frmModify = $("#frmModify");
			$("#artistList tbody tr").each(function(index) {
				$(this).click(function(e) {
					modLayer.css('top' ,e.pageY-10);
					modLayer.show();
					var td = $(this).find("td");
					frmModify.find("select[name='position_id']").val(td.eq(0).text());
					frmModify.find("select[name='program_id']").val(td.eq(2).text());
					frmModify.find("input[name='priority']").val(td.eq(5).text());
					frmModify.find("input[name='artist_idx']").val(td.eq(6).text());
					frmModify.find("input[name='artist_name']").val(td.eq(7).text());
					frmModify.find("input[name='role']").val(td.eq(8).text());
					// frmModify.find("input[name='photo_url']").val(td.eq(14).find("img").attr("src"));
					frmModify.find("input[name='photo_url']").val(td.eq(14).text());
					frmModify.find("select[name='use_yn']").val(td.eq(17).text());
				});
			});
			
			$("#btnClose").click(function() {
				modLayer.hide();
			});

		});
	
		function openArtistDetail(idx) {
			window.open('/star/starunse/artist_detail?idx='+idx, 'popup', 'width=650, height=650, toolbar=no,directories=no,scrollbars=yes,resizable=no,status=no,menubar=no,top=0,left=0');
		}

		function remove(position_id, program_id, artist_idx) {
			if (confirm('삭제?')) {
				document.frm2.position_id.value = position_id;
				document.frm2.program_id.value = program_id;
				document.frm2.artist_idx.value = artist_idx;
				document.frm2.submit();
			}
		}
		
		// 스타 검색 팝업
		function openArtistSearch() {
			openPopup("/imbc/artist/search", 500, 430);
		}

		
	</script>
</head>
<body>

<form method="post" name="frm2" id="frm2" action="/imbc/artist/remove_ok">
	<input type="hidden" name="position_id" />
	<input type="hidden" name="program_id" />
	<input type="hidden" name="artist_idx" />
</form>
<div id="wrap">
	<!-- Header -->
	<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/commons/header.php'; ?>
	<!--// Header -->
	
	<!-- Contents -->
	<div id="content">

		<h2>iMBC 스타 등록</h2>
		<div>
			<form id="frm" method="post" enctype="multipart/form-data" action="/imbc/artist/register_ok">
				<fieldset>
					<table class="basicTable" width="100%" cellpadding="2" cellspacing="1" border="0">
						<thead>
							<tr>
								<th>검색</th>
								<th>분류</th>
								<th>프로그램</th>
								<th>우선순위</th>
								<th>스타IDX</th>
								<th>이름</th>
								<th>배역</th>
								<th>사진URL</th>
							</tr>
						</thead>
						<tr>
							<td align="center"><input type="button" value="검색" onclick="openArtistSearch()" /></td>
							<td align="center">
								<select name="position_id">
<?	foreach ($display_position_list as $item) : ?>
									<option value="<?=$item['position_id']?>"><?=$item['position_name']?></option>
<?	endforeach ?>
								</select>
							</td>
							<td align="center">
								<select name="program_id">
<?	foreach ($program_list as $item) : ?>
									<option value="<?=$item['program_id']?>"><?=$item['program_name']?></option>
<?	endforeach ?>
								</select>
							</td>
							<td align="center"><input type="text" name="priority" size="2" value="1"/></td>
							<td align="center"><input type="text" name="artist_idx" size="3" readonly="readonly" class="roTxt" /></td>
							<td align="center"><input type="text" name="artist_name" readonly="readonly" class="roTxt" /></td>
							<td align="center"><input type="text" name="role" /></td>
							<td align="center"><input type="text" name="photo_url" id="photo_url" size="50" /></td>
						</tr>
					</table>
					<input type="submit" value="입력완료" />
				</fieldset>
			</form>	
		</div>

		<div id="modLayer" style="display:none; position:absolute; background:#FFF; z-index:3; border: 1px solid #000;">
			<h2>iMBC 스타 수정</h2>
			<form id="frmModify" method="post" enctype="multipart/form-data" action="/imbc/artist/modify_ok">
				<fieldset>
					<table class="basicTable" width="100%" cellpadding="2" cellspacing="1" border="0">
						<thead>
							<tr>
								<th>분류</th>
								<th>프로그램</th>
								<th>우선순위</th>
								<th>스타IDX</th>
								<th>이름</th>
								<th>배역</th>
								<th>사진URL</th>
								<th>노출여부</th>
							</tr>
						</thead>
						<tr>
							<td align="center">
								<select name="position_id">
<?	foreach ($display_position_list as $item) : ?>
									<option value="<?=$item['position_id']?>"><?=$item['position_name']?></option>
<?	endforeach ?>
								</select>
							</td>
							<td align="center">
								<select name="program_id">
<?	foreach ($program_list as $item) : ?>
									<option value="<?=$item['program_id']?>"><?=$item['program_name']?></option>
<?	endforeach ?>
								</select>
							</td>
							<td align="center"><input type="text" name="priority" size="2" value="1"/></td>
							<td align="center"><input type="text" name="artist_idx" size="3" readonly="readonly" class="roTxt" /></td>
							<td align="center"><input type="text" name="artist_name" readonly="readonly" class="roTxt" /></td>
							<td align="center"><input type="text" name="role" /></td>
							<td align="center"><input type="text" name="photo_url" size="50" /></td>
							<td align="center">
								<select name="use_yn">
									<option value="N">N</option>
									<option value="Y">Y</option>
								</select>			
							</td>					
						</tr>
					</table>
					<input type="submit" value="수정완료" />
					<input type="button" id="btnClose" value="닫기" />
				</fieldset>
			</form>	
		</div>

		<h2>iMBC 스타 관리 - 리스트</h2>
		<div>
			<a href="http://fortune.imbc.com/daemons/starunse.php">등록된 스타의 오늘의 운세 업데이트</a>
			<table id="artistList" class="basicTable" width="100%" cellpadding="2" cellspacing="1" border="0">
				<thead>
					<tr>
						<th colspan="2">분류</th>
						<th colspan="2">프로그램</th>
						<th>구분</th>
						<th>우선순위</th>
						<th>스타IDX</th>
						<th>이름</th>
						<th>배역</th>
						<th colspan="3">생년월일</th>
						<th>성별</th>
						<th>직업</th>
						<th style="display: none">사진URL</th>
						<th>사진</th>
						<th>오늘의 운세 요약</th>
						<th>노출</th>
						<!--th>스타정보</th-->
						<th>삭제</th>
					</tr>
				</thead>
				<tbody>
<?	foreach ($artist_list as $item) : ?>
					<tr>
						<td align="center"><?=$item['position_id']?></td>
						<td align="center"><?=$item['position_name']?></td>
						<td align="center"><?=$item['program_id']?></td>
						<td align="center"><?=$item['program_name']?></td>
						<td align="center"><?=$item['type']?></td>
						<td align="center"><?=$item['priority']?></td>
						<td align="center"><?=$item['artist_idx']?></td>
						<td align="center"><?=$item['artist_name']?></td>
						<td align="center"><?=$item['role']?></td>
						<td align="center"><?=$item['birth_yyyy']?></td>
						<td align="center"><?=$item['birth_mm']?></td>
						<td align="center"><?=$item['birth_dd']?></td>
						<td align="center"><?=$item['sex']?></td>
						<td align="center"><?=$item['job']?></td>
						<td align="center" style="display: none"><?=$item['photo_url']?></td>
						<td align="center"><img src="<?=!empty($item['photo_url']) ? $item['photo_url'] :  $item['profile_photo']?>" width="20" height="25" /></td>
						<td align="center"><?=mb_substr($item['today_summary'], 0,20,'utf-8')?>..</td>
						<td align="center"><?=$item['use_yn']?></td>
						<!--td align="center"><button onclick="openArtistDetail('<?=$item['artist_idx']?>')">보기/수정</button></td-->
						<td align="center"><button onclick="remove('<?=$item['position_id']?>','<?=$item['program_id']?>','<?=$item['artist_idx']?>')">삭제</button></td>
					</tr>
<?	endforeach ?>
				</tbody>
			</table>
		</div>
	</div>
	<!--// Contents -->
	
	<!-- Footer -->
	<? include_once $_SERVER['DOCUMENT_ROOT'].'/include/commons/footer.php'; ?>
	<!--// Footer -->
</div>
</body>
</html>